local hx__dili = fk.CreateSkill{
  name = "hx__dili",
  tags = { Skill.Wake },
}

local spec = {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__dili.name) and
      player:usedSkillTimes(hx__dili.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
    local skills = table.filter(player.player_skills, function(skill)
      return skill:isPlayerSkill(player)
    end)
    return #skills > player.maxHp
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choice = room:askToChoice(player, {
      skill_name = hx__dili.name,
      choices = {"0", "1", "2", "3", "4", "5", "6"},
      cancelable = false,
      prompt = "请选择减少至多六点体力上限，然后你将选择获得至多等量个技能",
    })
    room:changeMaxHp(player, -choice[1])
    if player.dead then return end
    local toget = room:askToChoices(player, {
      min_num = tonumber(choice[1]),
      max_num = tonumber(choice[1]),
      skill_name = hx__dili.name,
      choices = {"hx__shengzhi", "hx__quandao", "hx__chigang", "hx__qionglan", "hx__jiaohui", "hx__yuanlv"},
      cancelable = false,
      prompt = "请选择获得"..choice[1].."个技能",
    })
    room:handleAddLoseSkills(player, table.concat(toget, "|"))
  end,
}

hx__dili:addEffect(fk.EventAcquireSkill, spec)
hx__dili:addEffect(fk.MaxHpChanged, spec)

return hx__dili
